import { storeToRefs } from 'pinia';  
import { useCart } from '../store';
import { watch } from 'vue';
export function useTabBarBadge(){
  const cartStore = useCart();  
  const { total } = storeToRefs(cartStore); 
  // 定义一个函数来设置 tabBar 的 badge  
    const setBadge = () => {  
      uni.setTabBarBadge({  
        index: 2,  
        text: total.value+'',  
      });  
    };
    watch(total,()=>{
      onPageShow()
      // console.log(123);
    })
    const onPageShow = () => {  
        setBadge();  
      };  
      return {
        onPageShow
      }
}